package com.yanyuan.snio.part;

import lombok.extern.slf4j.Slf4j;

import java.nio.ByteBuffer;

/**
 * @author: yanyuan
 * @Date: 2021/3/4 11:34
 * @Description: 直接缓冲区和非直接缓冲区
 */
@Slf4j
public class NioP3Allocate {

    /**
     * 直接缓冲区
     */
    public void ioAllocateDirect(){
        ByteBuffer buf = ByteBuffer.allocateDirect(1024);
        log.info("direct = {} ", buf.isDirect());
    }

    /**
     * 直接缓冲区和非直接缓冲区
     */
    public void ioAllocate(){
        ByteBuffer buf = ByteBuffer.allocate(1024);
        log.info("direct = {} ", buf.isDirect());
    }

}
